
/**
 * Created by xiongshilin on 2017/4/13.
 */
(function(){
    ADF.figure.BootstrapColumnFigure = function() {
        ADF.figure.BootstrapColumnFigure.superclass.constructor.call(this);
        this.setLayoutManager(new COM.draw2d.XYLayout());
    };

    COM.util.defineClass(ADF.figure.BootstrapColumnFigure, AGEF.CompositeFigure, {
        paintChildren: function(graphics){
            ADF.figure.BootstrapColumnFigure.superclass.paintChildren.call(this, graphics);
        },
        useLocalCoordinates: function() {
            return true;
        },
        getPreferredSize: function() {
            var widgetBounds = this.getWidget().getBounds();
            var size = new COM.draw2d.Dimension(widgetBounds.width, widgetBounds.height);
            this.prefSize = size;
            return this.prefSize;
        },
        add: function(child, constraint, index){
            var newConstraint = this.addChildWidget(child, constraint, index);
            if(newConstraint) {
                constraint = newConstraint;
            }
            AGEF.CompositeFigure.superclass.add.call(this, child, constraint, index);
        },
        layout: function(){
            if(this.layoutManager){
                var children = this.getChildren(), that = this;
                children.forEach(function(child, index, array){
                    var widgetBounds = child.getWidget().getBounds();
                    var newConstraint = new COM.draw2d.Rectangle(widgetBounds.x, widgetBounds.y, widgetBounds.width, widgetBounds.height);
                    that.getLayoutManager().setConstraint(child, newConstraint);
                });
                this.layoutManager.layout(this);
            }
        }
    });
})();